package com.dg.gaming.client.gui
{
	import com.dg.gaming.api.common.util.Color;

	import flash.events.Event;

	import mx.containers.Canvas;

	public class ColouredSquare extends Canvas
	{
		private static const DEFAULT_COLOUR:Color=Color.white;

		private var color:Color;

		private var border:Boolean;

		public function ColouredSquare(color:Color, width:int, height:int, border:Boolean=false)
		{
			super();
			this.color=color;
			this.border=border;

			if (width != -1 && height != -1)
			{
				this.width=width;
				this.height=height;
			}
//			setStyle("borderStyle", "outset");
			setStyle("backgroundColor", color.getRGB());
			this.addEventListener("creationComplete", creationComplete);

		}

		public function creationComplete(evnt:Event):void
		{
			if (border)
			{

				this.graphics.lineStyle(2)
				this.graphics.drawRect(0, 0, width - 1, height - 1);

				this.graphics.lineStyle(2, Color.white.getRGB());
				this.graphics.drawRect(1, 1, width - 3, height - 3);
				this.graphics.lineStyle();

			}
		}



	}
}